<template>
  <div class="app-container">
    <el-dialog :title="'详情（'+form.productName+'）'" :visible.sync="dialogVisible" width="60%" append-to-body>
      <el-form ref="form" :model="form" disabled v-loading="loading">
        <div class="myTitle">基本信息</div>
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="订单编号" prop="orderNo">
              <div>{{ form.orderNo }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="下单日期" prop="createTime">
              <div>{{ form.createTime }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="生产来源" prop="produceType">
              <dict-tag :options="dict.type.ims_produce_type" :value="form.produceType"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="订单数量" prop="quantity">
              <div>{{ form.quantity }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="客户名称" prop="customerName">
              <div>{{ form.customerName }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="订单状态" prop="orderStatus">
              <dict-tag :options="dict.type.ims_produce_order_status" :value="form.orderStatus"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="优先级" prop="priority">
              <dict-tag :options="dict.type.ims_priority_level" :value="form.priority"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设计图纸" prop="imageUrl">
              <div style="display: flex">
                <el-link type="primary" v-if="form.imageUrl" @click="downloadFile(form.imageUrl)">{{ form.fileName }}
                </el-link>
                <div v-else>暂无</div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
         <el-col :span="24">
           <el-form-item label="商品规格" prop="skuDescCn">
             {{ form.skuDescCn || '-'}}
           </el-form-item>
         </el-col>
        </el-row>
      </el-form>
      <div class="myTitle">操作记录</div>
      <el-table
        :data="form.recordVoList"
        max-height="500"
      >
        <el-table-column type="index" label="序号" align="center"></el-table-column>
        <el-table-column prop="operStepName" label="工序名称" align="center"></el-table-column>
        <el-table-column prop="workerName" label="操作人" align="center"></el-table-column>
        <el-table-column prop="result" label="操作结果" align="center"></el-table-column>
        <el-table-column prop="createTime" label="操作时间" align="center"></el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getCustomOrder,
  listGoodAttr,
  listGood,
  listProvince, listCity, getProduceOrder
} from "../../../api/imsMng";

export default {
  dicts: ['ims_order_status', 'ims_produce_order_status', 'basic_good_source', 'sys_yes_no','ims_produce_type','ims_priority_level'],
  data() {
    return {
      flag: 0,
      type: 0, //0西单，1销售，2生成
      tabIndex: 0,
      tabName: '',
      loading: false,
      dialogVisible: false,
      form: {},
      attrList: [],
      provinceList: [],
      cityList: []
    }
  },
  methods: {
    show(form, type) {
      this.flag = 1
      this.type = type
      this.dialogVisible = true
      this.form = {}
      this.resetForm('form')
      this.getOrderDetail2(form.id)
    },
    downloadFile(url) {
      window.open(url)
    },
    getOrderDetail2(id) {
      this.loading = true
      getProduceOrder(id).then(res => {
        this.form = res.data
      }).finally(e => {
        this.loading = false
      })
    }
  }
}
</script>
